ROOT_DIR := ./../..

MAKEFILE_PARA := $(ROOT_DIR)/Makefile.env
#EX_INCLUDE = 

include $(MAKEFILE_PARA)

all : $(SUBDIRS)
$(SUBDIRS) : ECHO
	$(MAKE) -C $@

ECHO : 
	@echo "Compiling " $(SUBDIRS) "..." 

CXXFLAGS += -std=c++11
#LIBS += 
INCS += -I ./ -I ./..

TARGET1 = libluestore_static.a
TARGET2 = libbluestore.so

OBJ_SRCS=$(wildcard *.c *.cc)
NODIR=$(notdir $(OBJ_SRCS))
OBJS=$(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(NODIR)))

CFLAGS += -std=c++11
INCS += $(ROOT_DIR)/src
LIBS += -L $(ROOT_DIR)/out/lib -lkv -lcommon -lrocksdb -lsnappy -lz -lpthread -lboost_system -lboost_iostreams -ldl -laio

all: $(TARGET1) $(TARGET2)
$(TARGET1) : $(OBJS)
	$(AR) $@ $^
	mv $@ $(LIBOUT)

$(TARGET2) : $(OBJS)
	$(CXX) -shared $(CXXFLAGS)  $(LIBS) -o $@ $^
	mv $@ $(LIBOUT)

%.o : %.c
	@echo "Compiling" $< "..."
	$(CC) -c $^ $(CFLAGS) $(INCS) $(LIBS) -o $@

%.o : %.cc
	@echo "Compiling" $< "..."
	$(XX) -c $^ $(CXXFLAGS) $(INCS) $(LIBS) -o $@
clean :
	rm -rf *.o
